import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '../views/layout.vue'

Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
  VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
  {
    path: '/layout',
    name: 'layout',
    component: layout,
    children:[
      {
        path: 'book',
        name:"book",
        component:() => import('@/views/books/index.vue')
      },
      {
        path: 'broadcast',
        name:"broadcast",
        component:() => import('@/views/broadcast/index.vue')
      },
      {
        path: 'groups',
        name:"groups",
        component:() => import('@/views/groups/index.vue')
      },
      {
        path: '',
        name:"home",
        component:() => import('@/views/home/index.vue')
      },
      {
        path: 'me',
        name:"me",
        component:() => import('@/views/me/index.vue')
      },
    ]
  },
  {
    path:'/login',
    name:'login',
    component:() => import('@/views/login.vue')
  },
  {
    path:"/bookInfo/:zs",
    name:"BookInfo",
    component:() => import('@/views/books/bookInfo.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
